import numpy as np

lambda1= np.array(
        [[1.0/3.0, 1.0/3.0, 1.0/3.0]]
        )
weight1= [1.0];

lambda2= np.array( 
        [[2.0/3.0, 1.0/6.0, 1.0/6.0], 
         [1.0/6.0, 2.0/3.0, 1.0/6.0], [1.0/6.0, 1.0/6.0, 2.0/3.0]]) 
weight2= [1.0/3.0, 1.0/3.0, 1.0/3.0]

lambda3= np.array(
        [[1.0/3.0, 1.0/3.0, 1.0/3.0],
         [0.6, 0.2, 0.2],
         [0.2, 0.6, 0.2],
         [0.2, 0.2, 0.6]])
weight3= [-27.0/48.0, 25.0/48.0, 25.0/48.0, 25.0/48.0]


lambda4= np.array(
        [[0.108103018168070, 0.445948490915965, 0.445948490915965],
         [0.445948490915965, 0.108103018168070, 0.445948490915965],
         [0.445948490915965, 0.445948490915965, 0.108103018168070],
         [0.816847572980459, 0.091576213509771, 0.091576213509771],
         [0.091576213509771, 0.816847572980459, 0.091576213509771],
         [0.091576213509771, 0.091576213509771, 0.816847572980459]])
weight4= [0.223381589678011, 0.223381589678011, 0.223381589678011,
          0.109951743655322, 0.109951743655322, 0.109951743655322]

lambda5= np.array( 
        [[1.0/3.0,    1.0/3.0,    1.0/3.0],
         [0.059715871789770, 0.470142064105115, 0.470142064105115],
         [0.470142064105115, 0.059715871789770, 0.470142064105115],
         [0.470142064105115, 0.470142064105115, 0.059715871789770],
         [0.797426985353087, 0.101286507323456, 0.101286507323456],
         [0.101286507323456, 0.797426985353087, 0.101286507323456],
         [0.101286507323456, 0.101286507323456, 0.797426985353087]])
weight5= [0.225, 0.132394152788506, 0.132394152788506, 0.132394152788506, 
          0.125939180544827, 0.125939180544827, 0.125939180544827]

lambda6= np.array(
        [[0.249286745170910, 0.249286745170910, 0.501426509658180], 
         [0.249286745170910, 0.501426509658179, 0.249286745170911],
         [0.501426509658179, 0.249286745170910, 0.249286745170911],
         [0.063089014491502, 0.063089014491502, 0.873821971016996],
         [0.063089014491502, 0.873821971016996, 0.063089014491502],
         [0.873821971016996, 0.063089014491502, 0.063089014491502],
         [0.310352451033784, 0.636502499121399, 0.053145049844817],
         [0.636502499121399, 0.053145049844817, 0.310352451033784],
         [0.053145049844817, 0.310352451033784, 0.636502499121399],
         [0.636502499121399, 0.310352451033784, 0.053145049844817],
         [0.310352451033784, 0.053145049844817, 0.636502499121399],
         [0.053145049844817, 0.636502499121399, 0.310352451033784]])
weight6= [0.116786275726379, 0.116786275726379, 0.116786275726379, 
          0.050844906370207, 0.050844906370207, 0.050844906370207,
          0.082851075618374, 0.082851075618374, 0.082851075618374, 
          0.082851075618374, 0.082851075618374, 0.082851075618374]

lambda7= np.array( 
        [[0.333333333333333, 0.333333333333333, 0.333333333333334],
         [0.260345966079040, 0.260345966079040, 0.479308067841920],
         [0.260345966079040, 0.479308067841920, 0.260345966079040],
         [0.479308067841920, 0.260345966079040, 0.260345966079040],
         [0.065130102902216, 0.065130102902216, 0.869739794195568],
         [0.065130102902216, 0.869739794195568, 0.065130102902216],
         [0.869739794195568, 0.065130102902216, 0.065130102902216],
         [0.312865496004874, 0.638444188569810, 0.048690315425316],
         [0.638444188569810, 0.048690315425316, 0.312865496004874],
         [0.048690315425316, 0.312865496004874, 0.638444188569810],
         [0.638444188569810, 0.312865496004874, 0.048690315425316],
         [0.312865496004874, 0.048690315425316, 0.638444188569810],
         [0.048690315425316, 0.638444188569810, 0.312865496004874]])
weight7= [-0.149570044467682, 0.175615257433208, 0.175615257433208,
           0.175615257433208, 0.053347235608838, 0.053347235608838,
           0.053347235608838, 0.077113760890257, 0.077113760890257,
           0.077113760890257, 0.077113760890257, 0.077113760890257, 
           0.077113760890257]

lambda8= np.array( 
        [[0.333333333333333, 0.333333333333333, 0.333333333333334],  
         [0.081414823414554, 0.459292588292723, 0.459292588292723],
         [0.459292588292723, 0.081414823414554, 0.459292588292723],
         [0.459292588292723, 0.459292588292723, 0.081414823414554],
         [0.658861384496480, 0.170569307751760, 0.170569307751760],
         [0.170569307751760, 0.658861384496480, 0.170569307751760],
         [0.170569307751760, 0.170569307751760, 0.658861384496480],
         [0.898905543365938, 0.050547228317031, 0.050547228317031],
         [0.050547228317031, 0.898905543365938, 0.050547228317031],
         [0.050547228317031, 0.050547228317031, 0.898905543365938],
         [0.008394777409958, 0.263112829634638, 0.728492392955404],
         [0.008394777409958, 0.728492392955404, 0.263112829634638],
         [0.263112829634638, 0.008394777409958, 0.728492392955404],
         [0.728492392955404, 0.008394777409958, 0.263112829634638],
         [0.263112829634638, 0.728492392955404, 0.008394777409958],
         [0.728492392955404, 0.263112829634638, 0.008394777409958]])
weight8= [0.144315607677787, 0.095091634267285, 0.095091634267285,
          0.095091634267285, 0.103217370534718, 0.103217370534718,
          0.103217370534718, 0.032458497623198, 0.032458497623198,
          0.032458497623198, 0.027230314174435, 0.027230314174435,
          0.027230314174435, 0.027230314174435, 0.027230314174435,
          0.027230314174435]

lambda9= np.array(
        [[0.333333333333333, 0.333333333333333, 0.333333333333334],
         [0.020634961602525, 0.489682519198738, 0.489682519198737],
         [0.489682519198738, 0.020634961602525, 0.489682519198737],
         [0.489682519198738, 0.489682519198738, 0.020634961602524],
         [0.125820817014127, 0.437089591492937, 0.437089591492936],
         [0.437089591492937, 0.125820817014127, 0.437089591492936],
         [0.437089591492937, 0.437089591492937, 0.125820817014126],
         [0.623592928761935, 0.188203535619033, 0.188203535619032],
         [0.188203535619033, 0.623592928761935, 0.188203535619032],
         [0.188203535619033, 0.188203535619033, 0.623592928761934],
         [0.910540973211095, 0.044729513394453, 0.044729513394452],
         [0.044729513394453, 0.910540973211095, 0.044729513394452],
         [0.044729513394453, 0.044729513394453, 0.910540973211094],
         [0.036838412054736, 0.221962989160766, 0.741198598784498],
         [0.036838412054736, 0.741198598784498, 0.221962989160766],
         [0.221962989160766, 0.036838412054736, 0.741198598784498],
         [0.741198598784498, 0.036838412054736, 0.221962989160766],
         [0.221962989160766, 0.741198598784498, 0.036838412054736],
         [0.741198598784498, 0.221962989160766, 0.036838412054736]])
weight9= [0.097135796282799, 0.031334700227139, 0.031334700227139,
          0.031334700227139, 0.077827541004740, 0.077827541004740, 
          0.077827541004740, 0.079647738927210, 0.079647738927210,
          0.079647738927210, 0.025577675658698, 0.025577675658698,
          0.025577675658698, 0.043283539377289, 0.043283539377289,
          0.043283539377289, 0.043283539377289, 0.043283539377289,
          0.043283539377289]
quadpoints = [lambda1, lambda2, lambda3, lambda4, lambda5, lambda6, lambda7,
        lambda8, lambda9]
weight = [ weight1, weight2, weight3, weight4, weight5, weight6, weight7,
        weight8, weight9] 

class TriangleQuadrature:
    def __init__(self, order):
        self.order = order
        
    def get_number_of_quad_points(self):
        return quadpoints[self.order-1].shape[0]

    def get_gauss_point_and_weight(self, i):
        return (quadpoints[self.order-1][i, :], weight[self.order - 1][i])
    
